package com.codefish.codefish_blog.config;

import com.codefish.codefish_blog.config.interceptors.ArticleDataInterceptor;
import com.codefish.codefish_blog.config.interceptors.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author codefish
 * @version 1.0
 * @date 2022/04/11 上午 11:07
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加进行文章数据操作时验证jwt token的拦截器
        registry.addInterceptor(new ArticleDataInterceptor())
                .addPathPatterns("/articleOpe/**");
        //添加cookie中获取用户信息的拦截器
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**");
    }
}
